import pygame
import powerup
import barlines
import math

class SlowTime(powerup.PowerUp):
    def __init__(self,x_position,y_position,bar):
        super(SlowTime,self).__init__()
        self.image = pygame.image.load("../media/images/temp_time_slow.png").convert_alpha()
        self.rect = self.image.get_rect()
        self.rect.centerx = x_position
        self.rect.centery = y_position
        self.locY = y_position
        self.bar = bar
        self.velocity = -5
        self._vconst = -5
    def update(self,time):
        self.rect.centery = math.fabs(self.bar.curveLoc(self.rect.centerx)+self.locY-(self.bar.locY))
        self.velocity = self._vconst * time
        self.rect.move_ip(self.velocity,0)
    def draw(self,screen):
        screen.blit(self.image,self.rect)
    def collided(self,screen_rect):
        if self.rect.left < screen_rect.left:
            return True
        else:
            return False
    def collided_with(self,player):
        if self.rect.colliderect(player.rect):
            return True
        else:
            return False